package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.AccountService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @PROJECT_NAME: cloud2020
 * @DESCRIPTION:
 * @Author: csc
 * @DATE: 2023/4/6 14:54
 */
@RestController
public class AccountController {

    @Autowired
    private AccountService accountService;

    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/test")
    public String test(){
        redisTemplate.opsForValue().set("make","秦始皇");
        System.out.println(redisTemplate.opsForValue().get("mykey"));

        System.out.println("这是什么东西:");
        return "执行成功";
    }

    @GetMapping("/account/decrease")
    public String decrease(@RequestParam("userId") Long userId, @RequestParam("money") BigDecimal money){
        System.out.println("");
         accountService.decrease(userId,money);
        return "扣钱成功";
    }

}
